function loadModules() {
  const context = require.context("@/components", true, /\.vue|.jsx$/);
  const modulesFiles = context.keys();
  const config = modulesFiles.map((key) => ({ key, name: key.match(/^\.\/(.*)\.\w+$/i)[1] }));
  const modules = config.reduce( (cur, { key, name }) => ({ ...cur, [name]: context(key).default }), {});
  return modules;
};

export default (app) => {
  Object.entries(loadModules()).forEach(item => app.component.apply(app, item));
}